package com.lzp.wechat.entity.message;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@NoArgsConstructor
@XStreamAlias("xml")
@ApiModel(value = "消息基类")
public class BaseMessage {

    @XStreamAlias("ToUserName")
    @ApiModelProperty(value = "接收方帐号", notes = "收到的OpenID")
    private String toUserName;

    @XStreamAlias("FromUserName")
    @ApiModelProperty(value = "开发者微信号")
    private String fromUserName;

    @XStreamAlias("CreateTime")
    @ApiModelProperty(value = "消息创建时间", notes = "整型")
    private Integer createTime;

    @XStreamAlias("MsgType")
    @ApiModelProperty(value = "消息类型")
    private String msgType;

    public BaseMessage(Map<String, String> requestMap) {
        this.toUserName = requestMap.get("FromUserName");
        this.fromUserName = requestMap.get("ToUserName");
        this.createTime = (int) System.currentTimeMillis();
    }

}
